procedure countMax();

var
        sum, ms, mp, cur : longint;

begin
        ans := a[1];
        sum := 0;
        ms := 0;
        mp := 0;
        for i := 1 to n do begin
                inc(sum, a[i]);
                cur := sum - ms;
                if cur > ans then begin
                        ans := cur;
                        ansL := mp + 1;
                        ansR := i;
                end;
                if sum < ms then begin
                        ms := sum;
                        mp := i;
                end;
        end;
end;